package com.zhentao.controller;

import com.zhentao.entity.user.GoodsInfo;
import com.zhentao.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

@RestController
@RequestMapping("good")
public class GoodController {
    @Autowired
    private GoodService goodService;
    //首页商品搜索功能
//    @RequestMapping("goodSearch")
//    public List<GoodsInfo> goodSearch(String categoryName){
//        List<GoodsInfo> list=goodService.goodSearch(categoryName);
//        return list;
//    }
    //获取商品种类
    @RequestMapping("goodClass")
    public List<String> goodClass(){
        List<String> goodsName=goodService.goodClass();
        return goodsName;
    }
    //按照分类名称获取对应种类的商品
    @RequestMapping("classGoods")
    public List<GoodsInfo> classGoods(String categoryName){
        List<GoodsInfo> goods=goodService.classGoods(categoryName);
        return goods;
    }
    //添加到购物车
    //order_goods
    @RequestMapping("addToCar")
    public String addToCar(BigInteger userId, BigInteger goodsId, int quantity, int guigeId){
        String result=goodService.addToCar(userId,goodsId,quantity,guigeId);
        return result;
    }

    //清空购物车
    @RequestMapping("cleanCart")
    public String cleanCar(BigInteger userId){
        String result=goodService.cleanCar(userId);
        return result;
    }
    //用户下单
    @RequestMapping("makeOrder")
    public String makeOrder(){
        String result=goodService.makeOrder();
        return result;
    }
}
